<template>
	<div class="box">
		<HomeNotice :noticeSwiperSlides="noticeSwiperSlides"></HomeNotice>
		<!--<div v-if="noticeSwiperSlides.length==0 && env === 'edit'" style="height: 2.5rem;line-height: 2.5rem;">请配置数据</div>-->
	</div>
</template>

<script>
	import HomeNotice from "../../../real-components/HomeNotice";
	import { mapGetters } from "vuex";
	import { getPageTree, initDomTree } from "../../../utils/getPageTree";
	import axios from "axios";
	import { zxBase } from '../../../api/zxApi'
	export default {
		name: 'hello',
		data() {
			return {
				msg: '这是首页',
				page: "home",
				componentName: "HomeNotice",
				noticeSwiperSlides: [],
			}
		},
		computed: {
			...mapGetters([
				"getDomTree"
			]),
			pageTree() {
				return getPageTree(this, this.page);
			},
			env() {
				return window.environment; // 获取是否是编辑状态
			},
		},
		components: {
			HomeNotice,
		},
		methods: {
			//			queryNotice() {
			//				axios.get(api.local_host + '/bulletin/qryBulletinListFromH5?status=1&enterpriseid=' + api.enterpriseId).then((res) => {
			//					let data = res.data.data[0]
			//					this.noticeSwiperSlides = data
			//					for(var i=0;i<data.length;i++){
			//						this.noticeSwiperSlides.push(data[i].content);
			//						var obj = {};
			//						console.log(1,'kaishi ')
			//						obj.title = data[i].title;
			//						obj.rid = data[i].rid;
			//						this.noticeSwiperSlides.push(obj);
			//					}
			//				    console.log(this.noticeSwiperSlides,'公11111111111111111111111111');
			//				})
			//			},
			queryNotice() {
				let config = {
					url: window.api.customer_host + '/bulletinVue/qryBulletinListFromH5',
					method: 'POST',
					data: {
						"isPage": "false",
						"enterpriseCode": window.api.enterpriseCode,
						"storeId": localStorage.getItem('storeCode'),
						"start":1
					}
				}
				axios(config).then((res) => {
					if(res.data.returnCode === 1) {
						let data = res.data.data[0].results;
						this.noticeSwiperSlides = [];
						for(var i = 0; i < data.length; i++) {
							if(data[i].status == 1) {
								var obj = {};
								obj.title = data[i].title;
								obj.rid = data[i].rid;
								obj.imgUrl = data[i].imgUrl;
								this.noticeSwiperSlides.push(obj);
							}
						}
					}
				})
			},
			inite() {
				PSEvent.listen("NoticeUpdate", () => {
					this.queryNotice()
				});
				PSEvent.listen("changeStoreCode", () => {
					this.queryNotice()
				});
			},
			removeListen() {
				PSEvent.remove("changeStoreCode");
				PSEvent.remove("NoticeUpdate");
			},
		},
		created() {

		},
		mounted() {
			this.queryNotice()
			this.inite()
			// initDomTree(this.getDomTree[this.page]);
		},
		updated() {
			//页面更新完毕
			// initDomTree(this.getDomTree[this.page]);
		},
		beforeDestroy() {
			this.removeListen()
			//销毁虚拟页面
			//console.log("beforeDestroy");
		},
	}
</script>

<style>

</style>